package com.wac.user.controller;

import com.wac.common.component.NacosHelper;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wuancheng
 * @date 2023/9/8 15:42
 * @description
 */
@RestController
@RequestMapping("/health")
public class HealthController {

    @Resource
    private RedisTemplate redisTemplate;

    @Resource
    private NacosHelper nacosHelper;

    /**
     * 健康检查
     *
     * @return
     */
    @GetMapping("/check")
    public String getHealth(){
        return "success";
    }

    /**
     * redis测试
     *
     * @return
     */
    @GetMapping("/redis")
    public Long incr(){
        Long increment = redisTemplate.opsForValue().increment("wac", 1);
        return increment;
    }

    /**
     * 获取nacos上配置参数
     *
     * @return
     */
    @GetMapping("/nacos")
    public String getNacos(){
        return nacosHelper.getString("wac");
    }
}
